Micron Document
Fox's Git Mirrors

Node / RFnexus / dsp.git rns://e35de29a61974cd952fde3fe9c8500d5/RFnexus/dsp.git


-─
This is a work in progress and a long overdue attempt to bring all our DSP code together and make it reusable for our future projects.

Before using any of this you should enter the tests directory and execute "make".
This will check if your compiler is able to create binaries that are able to produce correct results when executed.

What we have included so far:


When working with Floating-point arithmetic we soon realize, that addition is not necessarily associative.
For example, whenever we need to add values with an ever decreasing magnitude to a running sum with an ever increasing magnitude, the Kahan summation algorithm comes in handy and helps keeping the error growth small.


Implemented are the follwing Window functions:
• Hann window
• Kaiser window


Implemented are the following finite impulse response filters):


There is also support for cascading, to improve roll-off while a correction factor helps to keep the same cutoff frequency.


A notch filter at DC helps removing DC bias.


Normalizers for periodic signals.


atan and atan2.


Exponentiation approximations.


When working on a device where multiplication is expensive, the CORDIC comes in handy for computing trigonometric functions.

The following implementations are a good (max 1 LSB error at full range) starting point for your own designs:
• Fixed-point atan2 implementation


Implemented are the following trigger functions):



The simple moving average gives us the mean of the last N data points.

• SMA1 computes the sum of its internal history buffer at each new input from scratch is and therefore very slow.
• SMA2 updates its internal sum using only the new input and the oldest value in the history buffer. It is therefore the fastest of all and works perfect with integers but suffers from drift when used with floats on sequences having a high dynamic range.
• SMA3 is based on SMA2 but uses the Kahan summation algorithm to reduce drift significantly.
• SMA4 uses a tree and only updates nodes that depend on the new input value and is slower than SMA3 but it has no drift.


The sliding window accelerator uses a tree and only updates nodes that depend on the new input value for the pairwise reduction.


Amortized O(1) moving extrema implementations of:

• Moving Minimum
• Moving Maximum


The Bip buffer provides contiguous block access to the last N value stored in a circular buffer.

Example:
T282828
DSP::BipBuffer<TYPE, NUM> history;
*snip*
const TYPE *buf = history(new_value);
*snip*
TYPE newest_value = buf[NUM-1];
TYPE previous_value = buf[NUM-2];
TYPE oldest_value = buf[0];
*snip*
DSP::FastFourierTransform<NUM, TYPE, -1> fwd;
TYPE out[NUM];
fwd(out, history(another_value));


A Digital delay line can be used to align signals with different delays - after filtering, for example.


A ring buffer based, fixed-size double-ended queue.


A fixed-size stack) with access to the first element.


Some calculus functions:

• Integrator


Some constants we need


Interface for reading and writing PCM data


Read and write WAV files


Interface for reading and writing pixel data


Read and write Netpbm files


• Algorithm for computing uniform and natural cubic splines#Algorithmforcomputingnaturalcubic_splines)
Very useful for data interpolation.


Faster alternative (no Inf/NaN handling) to the std::complex implementation.


Some everyday helpers:
• lerp function
• sinc function


Decibel calculation helpers.


When working with Analog-to-digital and Digital-to-analog converters, we often face the ugly truth, that we can't always have a precise Sampling) rate.
But if we can estimate the Sampling frequency offset, we can correct it by Resampling the sampled data.


Interpolation via frequency-domain zero padding.


Sometimes we only need trigonometric functions that stay on the unit circle:
• sine function


Some least mean squares filter implementations:
• Normalized Least Mean Squares
• Normalized Complex Least Mean Squares


Served by rngit 1.4.1 - Generated in 0.05s